package com.ironman.analyze.orm.flex;

import com.ironman.analyze.common.dataobject.TrainingData;
import com.ironman.analyze.common.dataobject.Wind;
import com.mybatisflex.annotation.UseDataSource;
import com.mybatisflex.core.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;


/**
 * description TODO
 * company 铁人科技
 *
 * @author 陈浩杰
 * @date 2024/4/11 17:17
 */
@UseDataSource("td")
public interface TrainingDataMapper extends BaseMapper<TrainingData> {

    @Select("SELECT `ts`,`longitude`,`latitude`,`gps_speed`,`gps_direction`,`declination`,`valid`,`rol`,`yaw`,`heart_rate`,`training_boat_code` FROM training_data_${subTableName} WHERE ts >= #{start} AND ts <= #{end} ORDER BY ts")
    List<TrainingData> selectSubTable(@Param("subTableName") String subTableName, @Param("start") Date start, @Param("end") Date end);

    @Select("SELECT `ts`,`wind_speed`,`wind_direction`,`training_boat_code` FROM wind WHERE tenant_code = #{tenantCode} AND ts >= #{start} AND ts <= #{end} ORDER BY ts")
    List<Wind> selectWind(@Param("tenantCode") String tenantCode, @Param("start") Date start, @Param("end") Date end);
}
